﻿using System;
using System.Collections.Generic;
using System.Text;
using WeatherSystem.Application.ContentAdapter.Base;
using WeatherSystem.Application.MsgHandler;
using WeatherSystem.Data.Response;

namespace WeatherSystem.Application.ContentAdapter.TextAdapter
{
    abstract class TextAdapterBase : Adapter 
    {
        /// <summary>
        /// 关键字
        /// </summary>
        public abstract string KeyWord { get; }
        protected abstract AdaptMode AdaptMode { get; }
        public bool Adapt(MsgHandler.TextMessage message)
        {
            var result = false;
            switch (AdaptMode)
            {
                case AdaptMode.Contain:
                    if (message.Content.IndexOf(KeyWord) != -1) result = true;
                    break;
                case AdaptMode.Head:
                    if (message.Content.IndexOf(KeyWord) == 0) result = true;
                    break;
            }
            return result;
        }
        public abstract ResponseMessageBase Handle(Message message);
    }
    /// <summary>
    /// 关键字匹配模式
    /// </summary>
    enum AdaptMode
    {
        /// <summary>
        /// 包含关键字
        /// </summary>
        Contain,
        /// <summary>
        /// 开头为关键字
        /// </summary>
        Head
    }
}
